home *** CD-ROM | disk | FTP | other *** search
- Path: news.ultranet.com!usenet
- From: Ken Brady <kbrady@ultranet.com>
- Newsgroups: comp.lang.c++
- Subject: Why can't I use this function prototype????
- Date: Tue, 9 Jan 1996 20:59:32 EST
- Organization: UltraNet Communications, Inc.
- Message-ID: <60ju5934@kbrady.ultranet.com>
- Reply-To: Ken Brady <kbrady@ultranet.com>
- NNTP-Posting-Host: 205.246.13.244
- X-Mailer: Post Road Mailer (Green Edition Ver 1.05a)
-
- I have a header file with something like:
-
- /* pm_app.hpp */
- Class PmApplication {
- PmApplication();
- .... //member and method definitions here
- };
-
- PmApplication *Application(); //a typical function prototype??
- // other function prototypes here
- // end pm_app.hpp
-
- My implementation is, of course, hidden from users of the header file:
-
- /* pm_app.cpp */
- PmApplication *App=NULL; //a global variable
-
- PmApplication *Application() {return App;}
-
- PmApplication::PmApplication()
- { App = this;}
-
- ... // more implementations
-
-
-
- So, I try to use this function:
-
- /* myapp.cpp */
- #include "pm_app.hpp"
-
- void MyProcedure()
- { ...
- PmApp *A=Application(); //won't compile!!
- ...
- }
-
- The compiler error is:
- myapp.cpp(53): Error! E043: (col 1) static function 'Application' has
- not been defined
- myapp.cpp(53): Note! N392: (col 1) 'PmApp * Application( void )'
- defined in: d:\c\lib\pm_app.hpp(55) (col 15)
-
- Why has the compiler singled out this function prototype as being
- somehow different from all of my other function prototypes? Why is it
- 'static'?
-
- I've tried implementing the global variable directly, i.e., defining
- the global variable 'PmApplication *App=NULL' in the header file.
- Then, the linker tells me that it has redefined App for every file that
- includes pm_app.hpp. How else can I implement a global variable?
-
- Help appreciated ...
-
-
-
-
- __________ `-'.
- /| o o O o ___:
- \ O ____0 /
- (//W ||
- ||| || -CyberPriestess-
- "" ""
- DONT HAVE A COW, MAN
-
-
-
-